# coding utf-8


# def load_file():
#     global f, content
#
#     try:
#         f = open("3-property.py", "r", encoding="utf-8")
#         content = f.read()
#     except FileNotFoundError as e:
#         print(e)
#     finally:
#         if f:
#             f.close()
#     return content
#
#
# print(load_file())
#
# with open("3-property.py", "r", encoding="utf-8") as f:
#     content = f.read()
#
# print(content)


# # 上下文管理器(ContextManager)
# class Agree:
#
#     # 上文方法
#     def __enter__(self):
#         print('enter')
#         return self
#
#     # 下文方法
#     def __exit__(self, exc_type, exc_val, exc_tb):
#         print('进入下文方法')
#         if exc_type is None:
#             print('PASS')
#         else:
#             print('Type: ', exc_type)
#             print('Value:', exc_val)
#             print('TraceBack:', exc_tb)
#         # 返回值决定了捕获的异常是否继续向外抛出
#         # 如果是 False 那么就会继续向外抛出，程序会看到系统提示的异常信息
#         # 如果是 True 不会向外抛出，程序看不到系统提示信息，只能看到else中的输出
#         return True
#
#     def do_something(self):
#         print('do something')
#         bar = 1 / 0
#         return bar + 10
#
#
# with Agree() as agree:
#     agree.do_something()
